<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>08定时器</title>
    <script>
        window.onload = function (){
            var demo = document.getElementById("demo");
            var num=1;
            function myInterval(){
                num++;
                demo.innerHTML = num;
            }
            window.setInterval(myInterval,1000);
        }
    </script>
</head>
<body>
<div id="demo"></div>
</body>
</html>